﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Client.App.Services
{
    public class TimeStatisticsService : BaseStatisticsService<TimeSpan>
    {
        #region Constructors

        public TimeStatisticsService(Func<TimeSpan> action, int attempts) 
            : base(action, attempts)
        {
        }

        #endregion

        #region Methods

        public override TimeSpan GetAverage(IEnumerable<TimeSpan> values)
        {
            var averageTicks = (long) Math.Truncate(values.Select(timeSpan => timeSpan.Ticks).Average());
            return new TimeSpan(averageTicks);
        }

        #endregion
    }
}
